import 'package:gluz/generated/json/base/json_field.dart';
import 'dart:convert';
import 'package:get/get.dart';

import '../../generated/json/country_entity.g.dart';



@JsonSerializable()
class CountryEntity {
  static List<CountryEntity> countryList = [
    CountryEntity.init(code: "86", name: "中国".tr, image: "assets/images/ic_中国.png", id: 0),
		CountryEntity.init(code: "7", name: "俄罗斯".tr, image: "assets/images/ic_俄罗斯.png", id: 1),
		CountryEntity.init(code: "7", name: "哈萨克斯坦".tr, image: "assets/images/ic_哈萨克斯坦.png", id: 2),
		CountryEntity.init(code: "375", name: "白俄罗斯".tr, image: "assets/images/ic_白俄罗斯.png", id: 3),
		CountryEntity.init(code: "996", name: "吉尔吉斯斯坦".tr, image: "assets/images/ic_吉尔吉斯斯坦.png", id: 4),
		CountryEntity.init(code: "998", name: "乌兹别克斯坦".tr, image: "assets/images/ic_乌兹别克斯坦.png", id: 5),
		CountryEntity.init(code: "993", name: "土库曼斯坦".tr, image: "assets/images/ic_土库曼斯坦.png", id: 6),
		CountryEntity.init(code: "380", name: "乌克兰".tr, image: "assets/images/ic_乌克兰.png", id: 7),
		CountryEntity.init(code: "992", name: "塔吉克斯坦".tr, image: "assets/images/ic_塔吉克斯坦.png", id: 8),
  ];

  static String getCountryImage(String code) {
    for (var e in countryList) {
      if (e.code == code) {
        return e.image;
      }
    }
    return 'assets/images/ic_中国.png';
  }

  static String getCountryImage2(String id) {
    return 'assets/images/country/country_$id.png';
  }

  late String code;
  late String name;
  late String image;
  late int id;

  CountryEntity();

  CountryEntity.init({
    required this.code,
    required this.name,
    required this.image,
    required this.id,
  });

  factory CountryEntity.fromJson(Map<String, dynamic> json) =>
      $CountryEntityFromJson(json);

  Map<String, dynamic> toJson() => $CountryEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
